//声明变量
var OPERATION = false;    // 在编辑文字状态下不允许使用删除快捷方式、拖动 //operation
var TEMPLATEAPI = {}; // 所有可操作的模板API  templateApi
var ALLSCRIPT = {}; //allScript
var MAXLENELEMENT = {};//maxLenElement
var MINSIZE = {width: 1, height: 1};// 元素最小宽高 minSize
var IS_EXIT_SAVE = true;   // 退出前是否保存 is_exit_save
var IS_FULL_SCREEN = false;    // 是否全屏 is_full_screen
var NOWEL = "";//nowEl
var IS_FIRST_ELEMENT = true; //is_first_element
var IS_SELECT = false; // is_select
var IS_MOVE=true;
var IS_PX=false;//是否改分辨率
var IS_BJ=false;//是否改分背景
var IS_SAME=true;//机器号是否相同
var SAME_CP='';//相同机器号
var cp_width="46";//机器默认宽度
var cp_size="12";//机器默认字号

// 生成随机数
function generateMixed(n) {
    var chars = ['0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"];
    var res = "";
    for(var i = 0; i < n ; i ++) {
        var id = Math.ceil(Math.random()*35);
        res += chars[id];
    }
    return res;
}

// 删除数组指定值
Array.prototype.indexOf = function(val) {
    for (var i = 0; i < this.length; i++) {
        if (this[i] == val) return i;
    }
    return -1;
};
Array.prototype.remove = function(val) {
    var index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
    }
};

//检测是否输入整数
function validateIntNumber(val){
    var reg = new RegExp("^[0-9]*$");
    if(!reg.test(val)){
        return false;
    }
    if(!/^[0-9]*$/.test(val)){
        return false
    }
    return true;
}

//获取元素大小位移
function resizeToolbar(props){
    $(".toolbar-size input[data-type=width]").val(parseInt(props.w));
    $(".toolbar-size input[data-type=height]").val(parseInt(props.h));
    $(".toolbar-size input[data-type=x]").val(parseInt(props.x));
    $(".toolbar-size input[data-type=y]").val(parseInt(props.y));
}

//获取机器号
function resizeCPNum(val){
    $("#CPNum input[data-type=cpnum]").val(val);
}

function cpWSetShow(){
    if($("#canvas_container .cpNum").length !== 0){
        $(".cpWSet").show();
    }else{
        $(".cpWSet").hide();
    }
}